<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="mailbox-mboxmessage.html" />
<link rel="prev" href="mailbox-message-objects.html" />
<link rel="parent" href="mailbox-message-objects.html" />
<link rel="next" href="mailbox-mboxmessage.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>7.3.2.1 MaildirMessage</title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="7.3.2 message objects"
  href="mailbox-message-objects.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="7.3.2 message objects"
  href="mailbox-message-objects.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="7.3.2.2 mboxMessage"
  href="mailbox-mboxmessage.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="mailbox-message-objects.html">7.3.2 Message objects</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="mailbox-message-objects.html">7.3.2 Message objects</a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="mailbox-mboxmessage.html">7.3.2.2 mboxMessage</a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h3><a name="SECTION009321000000000000000"></a>
<a name="mailbox-maildirmessage"></a>
<br>
7.3.2.1 <tt class="class">MaildirMessage</tt>
</h3>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-1409' xml:id='l2h-1409' class="class">MaildirMessage</tt></b>(</nobr></td>
  <td><var></var><big>[</big><var>message</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
A message with Maildir-specific behaviors. Parameter <var>message</var>
has the same meaning as with the <tt class="class">Message</tt> constructor.
</dl>

<p>
Typically, a mail user agent application moves all of the messages in the
<span class="file">new</span> subdirectory to the <span class="file">cur</span> subdirectory after the first time the
user opens and closes the mailbox, recording that the messages are old whether
or not they've actually been read. Each message in <span class="file">cur</span> has an "info"
section added to its file name to store information about its state. (Some mail
readers may also add an "info" section to messages in <span class="file">new</span>.) The "info"
section may take one of two forms: it may contain "2," followed by a list of
standardized flags (e.g., "2,FR") or it may contain "1," followed by so-called
experimental information. Standard flags for Maildir messages are as follows:

<p>
<div class="center"><table class="realtable">
  <thead>
    <tr>
      <th class="left"  >Flag</th>
      <th class="left"  >Meaning</th>
      <th class="left"  >Explanation</th>
      </tr>
    </thead>
  <tbody>
    <tr><td class="left"   valign="baseline">D</td>
        <td class="left"  >Draft</td>
        <td class="left"  >Under composition</td></tr>
    <tr><td class="left"   valign="baseline">F</td>
        <td class="left"  >Flagged</td>
        <td class="left"  >Marked as important</td></tr>
    <tr><td class="left"   valign="baseline">P</td>
        <td class="left"  >Passed</td>
        <td class="left"  >Forwarded, resent, or bounced</td></tr>
    <tr><td class="left"   valign="baseline">R</td>
        <td class="left"  >Replied</td>
        <td class="left"  >Replied to</td></tr>
    <tr><td class="left"   valign="baseline">S</td>
        <td class="left"  >Seen</td>
        <td class="left"  >Read</td></tr>
    <tr><td class="left"   valign="baseline">T</td>
        <td class="left"  >Trashed</td>
        <td class="left"  >Marked for subsequent deletion</td></tr></tbody>
</table></div>

<p>
<tt class="class">MaildirMessage</tt> instances offer the following methods:

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1410' xml:id='l2h-1410' class="method">get_subdir</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Return either "new" (if the message should be stored in the <span class="file">new</span>
subdirectory) or "cur" (if the message should be stored in the <span class="file">cur</span>
subdirectory). <span class="note"><b class="label">Note:</b>
A message is typically moved from <span class="file">new</span> to <span class="file">cur</span>
after its mailbox has been accessed, whether or not the message is has been
read. A message <code>msg</code> has been read if <code>"S" not in msg.get_flags()</code>
is <code>True</code>.</span>
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1411' xml:id='l2h-1411' class="method">set_subdir</tt></b>(</nobr></td>
  <td><var>subdir</var>)</td></tr></table></dt>
<dd>
Set the subdirectory the message should be stored in. Parameter <var>subdir</var>
must be either "new" or "cur".
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1412' xml:id='l2h-1412' class="method">get_flags</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Return a string specifying the flags that are currently set. If the message
complies with the standard Maildir format, the result is the concatenation in
alphabetical order of zero or one occurrence of each of "<tt class="character">D</tt>",
"<tt class="character">F</tt>", "<tt class="character">P</tt>", "<tt class="character">R</tt>", "<tt class="character">S</tt>", and "<tt class="character">T</tt>".
The empty string is returned if no flags are set or if "info" contains
experimental semantics.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1413' xml:id='l2h-1413' class="method">set_flags</tt></b>(</nobr></td>
  <td><var>flags</var>)</td></tr></table></dt>
<dd>
Set the flags specified by <var>flags</var> and unset all others.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1414' xml:id='l2h-1414' class="method">add_flag</tt></b>(</nobr></td>
  <td><var>flag</var>)</td></tr></table></dt>
<dd>
Set the flag(s) specified by <var>flag</var> without changing other flags. To add
more than one flag at a time, <var>flag</var> may be a string of more than one
character. The current "info" is overwritten whether or not it contains
experimental information rather than
flags.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1415' xml:id='l2h-1415' class="method">remove_flag</tt></b>(</nobr></td>
  <td><var>flag</var>)</td></tr></table></dt>
<dd>
Unset the flag(s) specified by <var>flag</var> without changing other flags. To
remove more than one flag at a time, <var>flag</var> maybe a string of more than one
character. If "info" contains experimental information rather than flags, the
current "info" is not modified.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1416' xml:id='l2h-1416' class="method">get_date</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Return the delivery date of the message as a floating-point number representing
seconds since the epoch.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1417' xml:id='l2h-1417' class="method">set_date</tt></b>(</nobr></td>
  <td><var>date</var>)</td></tr></table></dt>
<dd>
Set the delivery date of the message to <var>date</var>, a floating-point number
representing seconds since the epoch.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1418' xml:id='l2h-1418' class="method">get_info</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Return a string containing the "info" for a message. This is useful for
accessing and modifying "info" that is experimental (i.e., not a list of
flags).
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1419' xml:id='l2h-1419' class="method">set_info</tt></b>(</nobr></td>
  <td><var>info</var>)</td></tr></table></dt>
<dd>
Set "info" to <var>info</var>, which should be a string.
</dl>

<p>
When a <tt class="class">MaildirMessage</tt> instance is created based upon an
<tt class="class">mboxMessage</tt> or <tt class="class">MMDFMessage</tt> instance, the <span class="mailheader">Status:</span>
and <span class="mailheader">X-Status:</span> headers are omitted and the following conversions
take place:

<p>
<div class="center"><table class="realtable">
  <thead>
    <tr>
      <th class="left"  >Resulting state</th>
      <th class="left"  ><tt class="class">mboxMessage</tt> or <tt class="class">MMDFMessage</tt> state</th>
      </tr>
    </thead>
  <tbody>
    <tr><td class="left"   valign="baseline">"cur" subdirectory</td>
        <td class="left"  >O flag</td></tr>
    <tr><td class="left"   valign="baseline">F flag</td>
        <td class="left"  >F flag</td></tr>
    <tr><td class="left"   valign="baseline">R flag</td>
        <td class="left"  >A flag</td></tr>
    <tr><td class="left"   valign="baseline">S flag</td>
        <td class="left"  >R flag</td></tr>
    <tr><td class="left"   valign="baseline">T flag</td>
        <td class="left"  >D flag</td></tr></tbody>
</table></div>

<p>
When a <tt class="class">MaildirMessage</tt> instance is created based upon an
<tt class="class">MHMessage</tt> instance, the following conversions take place:

<p>
<div class="center"><table class="realtable">
  <thead>
    <tr>
      <th class="left"  >Resulting state</th>
      <th class="left"  ><tt class="class">MHMessage</tt> state</th>
      </tr>
    </thead>
  <tbody>
    <tr><td class="left"   valign="baseline">"cur" subdirectory</td>
        <td class="left"  >"unseen" sequence</td></tr>
    <tr><td class="left"   valign="baseline">"cur" subdirectory and S flag</td>
        <td class="left"  >no "unseen" sequence</td></tr>
    <tr><td class="left"   valign="baseline">F flag</td>
        <td class="left"  >"flagged" sequence</td></tr>
    <tr><td class="left"   valign="baseline">R flag</td>
        <td class="left"  >"replied" sequence</td></tr></tbody>
</table></div>

<p>
When a <tt class="class">MaildirMessage</tt> instance is created based upon a
<tt class="class">BabylMessage</tt> instance, the following conversions take place:

<p>
<div class="center"><table class="realtable">
  <thead>
    <tr>
      <th class="left"  >Resulting state</th>
      <th class="left"  ><tt class="class">BabylMessage</tt> state</th>
      </tr>
    </thead>
  <tbody>
    <tr><td class="left"   valign="baseline">"cur" subdirectory</td>
        <td class="left"  >"unseen" label</td></tr>
    <tr><td class="left"   valign="baseline">"cur" subdirectory and S flag</td>
        <td class="left"  >no "unseen" label</td></tr>
    <tr><td class="left"   valign="baseline">P flag</td>
        <td class="left"  >"forwarded" or "resent" label</td></tr>
    <tr><td class="left"   valign="baseline">R flag</td>
        <td class="left"  >"answered" label</td></tr>
    <tr><td class="left"   valign="baseline">T flag</td>
        <td class="left"  >"deleted" label</td></tr></tbody>
</table></div>

<p>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="7.3.2 message objects"
  href="mailbox-message-objects.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="7.3.2 message objects"
  href="mailbox-message-objects.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="7.3.2.2 mboxMessage"
  href="mailbox-mboxmessage.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="mailbox-message-objects.html">7.3.2 Message objects</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="mailbox-message-objects.html">7.3.2 Message objects</a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="mailbox-mboxmessage.html">7.3.2.2 mboxMessage</a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
